<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var person = {
            name: 'xianyu',
            sayName: function () {
                console.log(this)
                console.log(this.name)
            }
        }
        // 此时this指向person（指向的调用函数的对象）
        person.sayName();

        var name = "windowsName";
        var a = {
            name: "Cherry",
            fn: function () {
                console.log(this.name);
            }
        }
        // Cherry，如果a对象中没有定义name，那么name是undefined
        window.a.fn();

        function fn() {
            var name = 'Cherry';

            function innerFunction() {
                console.log(this.name);  
            }

            innerFunction();
        }
        // windowsName
        fn()



    </script>
</body>

</html>